<?php
ob_start();
header("Content-type:text/html;charset=utf-8");
ini_set('memory_limit','88M');
ini_set('max_execution_time','0');
date_default_timezone_set('Asia/Shanghai');
error_reporting(0);
$date   = date('Y-m-d');//当天下午16:30之前的订单
$dateex = explode('-',$date);
$stime  = time();
$stime1 = mktime('0','0','0',$dateex[1],$dateex[2],$dateex[0]);
$stime2 = mktime('0','10','0',$dateex[1],$dateex[2],$dateex[0]);
if($stime>=$stime1 && $stime<=$stime2){
}else{
    echo "fuck you mom!!!get out(return money)!! \n";
    exit;
}

/*
* 每天的晚上0.01开始执行此脚本，仅执行一次
* sql_backup:    

ALTER TABLE `clt_licai_order` ADD COLUMN `status`  smallint(1) NOT NULL DEFAULT 1 COMMENT '1已执行2未执行' AFTER `summey`;
ALTER TABLE `clt_users` ADD COLUMN `is_deal`  smallint(1) NOT NULL DEFAULT 1 COMMENT '1已执行2未执行' ;

* crontab脚本：     1 0 * * * * php -f  /crontab_reset.php 
*/

include 'config.php';

/*----------链接mysql数据库  start------------*/
$conn = @mysql_connect($db_host,$db_user,$db_pwd) or die('mysql server failed!!');
@mysql_query('set names utf8',$conn);
@mysql_select_db($db_name,$conn) or die('can not find mysql dbname:'.$db_name);
/*----------链接mysql数据库  end------------*/

/*----------常用方法封装  start------------*/
function querys($sql){
	return @mysql_query($sql);
}

function getone($sql){
    $query = querys($sql);
    return @mysql_fetch_assoc($query);
}




$sys=getone("select * from clt_system where id=1");
$xingqi = date("w");
if($sys['jingtai']=='close'){
    echo "fuck you!";
    exit;
}
$time=unserialize($sys['jingtai_ff']);
if(in_array($xingqi, $time) || in_array(8, $time)) {
    $sql = "update clt_licai_order set `status`=2";
    querys($sql);
    sleep(1);
    $sql = "update clt_users set `is_deal`=2";
    querys($sql);
    echo '重置状态成功！';
}else {
    echo "fuck you!!";
    exit;
}


?>